#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <QObject>
#include <QTcpSocket>
#include <QByteArray>

class TcpClient : public QObject
{
    Q_OBJECT
public:
    TcpClient(QObject *object);
    ~TcpClient();

private:


    /**
        QAbstractSocket::UnconnectedState：未连接状态
        QAbstractSocket::HostLookupState：正在解析主机名
        QAbstractSocket::ConnectingState：正在尝试连接
        QAbstractSocket::ConnectedState：已连接
        QAbstractSocket::BoundState：已绑定
        QAbstractSocket::ClosingState：正在关闭
        QAbstractSocket::ListeningState：正在监听
     */
    enum SocketState {
        UnconnectedState=0,
        HostLookupState=1,
        ConnectingState=2,
        ConnectedState=3,
        BoundState=4,
        ListeningState=5,
        ClosingState=6
    };

    QTcpSocket* m_tcpSocket;

    int m_tcpConnectStatus = 0;

    QByteArray m_receiveData;

public slots:
    void sendMessage(QByteArray data);
    int getConnectStatus();

signals:
    void receiveData(QString data);
};

#endif // TCPCLIENT_H
